﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ch_read.aspx.cs" Inherits="manage_channel_CreatLabel_ch_read" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>创建标签</title>
<link href="../../../sysImages/<% Response.Write(NetCMS.Config.UIConfig.CssPath()); %>/css/css.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript" src="../../../configuration/js/Prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="../../../configuration/js/Public.js"></script>
<script language="JavaScript" type="text/javascript" src="../../../configuration/js/jsPublic.js"></script>
<script type="text/javascript" src="../../../editor/fckeditor.js"></script>
<style type="text/css">
</style>
</head>
<body>
 <form id="ListLabel" runat="server">
    <div style="padding:2px 5px;">
    <table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" class="table">
       <tr class="TR_BG_list">
        <td align="right" class="navi_link" style="width:105px">引用样式</td>
        <td>
        <asp:DropDownList ID="StyleID" runat="server" Width="180px" onchange="showSty(this.value);">
            <asp:ListItem Value="0">固定样式</asp:ListItem>
            <asp:ListItem Value="1">自定义样式</asp:ListItem>
        </asp:DropDownList>
        <span id="TrStyleID">
        <asp:DropDownList ID="gstyleID" runat="server">
        </asp:DropDownList>
        </span>
        </td>
       </tr>
       
       <tr class="TR_BG_list" id="TrstContent" style="display:none;">
       <td align="right">
            自定义样式
            <div style="height:3px;margin:2px 0 4px 0;"></div>
            <input name="saveStyled" value="保存样式" type="button" onclick="ShowStyle();" />
            <div id="showOther" style="display:none;">
            <div style="height:3px;border-bottom:1px dotted #999999;margin:2px 0 4px 0;"></div>
            <asp:TextBox ID="StyleName" Width="94px" runat="server"></asp:TextBox>
            <div style="height:3px;border-bottom:1px dotted #999999;margin:2px 0 4px 0;"></div>
            <asp:DropDownList ID="StyleClassID"  Width="100px" runat="server">
            </asp:DropDownList>
            <div style="height:3px;border-bottom:1px dotted #999999;margin:2px 0 4px 0;"></div>
            <input name="saveStyle" id="saveStyle" value="保存" type="button" onclick="savePostStyle();" />
            <div id="sResultHTML" class="reshow"></div>
            </div>
       </td>
        <td   class="navi_link">
        <asp:DropDownList ID="ChannelStyle" runat="server" onchange="getValue(this.value);">
        <asp:ListItem Value="">01.选择字段</asp:ListItem>
        </asp:DropDownList>
        <label id="style_base" runat="server" />
        <label id="style_class" runat="server" />
        <label id="style_special" runat="server" /> 
        <br />                
<%--        <script type="text/javascript" language="JavaScript">
         window.onload = function()
            {
            var sBasePath = "../../../editor/"
            var oFCKeditor = new FCKeditor('UserDefined') ;
            oFCKeditor.BasePath	= sBasePath ;
            oFCKeditor.Width = '100%' ;
            oFCKeditor.ToolbarSet = 'NT_Basicstyle';
            oFCKeditor.Height = '200px' ;	
            oFCKeditor.ReplaceTextarea() ;
            }
        </script>--%>
        <textarea rows="8" cols="80" name="UserDefined" id="UserDefined" ></textarea>
        <script language="javascript" type="text/javascript">
        function ShowStyle()
        {
            if(document.getElementById("showOther").style.display=="none")
            {
               document.getElementById("showOther").style.display="";
            }
        }
        function savePostStyle()
        {
            var saveStyle= document.getElementById("saveStyle");
            var sname=document.getElementById("StyleName");
            var StyleClassID=document.getElementById("StyleClassID");
            if(sname.value=="")
            {
                alert('请填写样式名称');
                sname.focus();
                return false;
            }
            if(StyleClassID.value=="")
            {
                alert('请选择分类，如果没有分类，请在样式中创建');
                return false;
            }
            //var olEditor = FCKeditorAPI.GetInstance("UserDefined");
            var gtemproot = document.getElementById("UserDefined").value;
            
            var url="SaveStyle.aspx"
            var actionstr="StyleName="+escape(sname.value)+"&ClassID="+escape(StyleClassID.value)+"&Content="+escape(gtemproot)+"&ChID=<%Response.Write(Request.QueryString["ChID"]); %>";
            var divID = "sResultHTML";
            pubPostajax(url,actionstr,divID)
        }
        </script> 
       </td>
       </tr>
      <tr class="TR_BG_list">
        <td align="right" class="navi_link"></td>
        <td align="left" class="navi_link">&nbsp;<input class="form" type="button" value=" 确 定 "  onclick="javascript:ReturnDivValue();" />&nbsp;<input class="form" type="button" value=" 关 闭 "  onclick="javascript:CloseDiv();" /></td>
      </tr>
     </table>
    </div>
 </form>
</body>
</html>
<script language="javascript" type="text/javascript">
function showSty(obj)
{
    if(obj=="1")
    {
        document.getElementById("TrstContent").style.display="";
        document.getElementById("TrStyleID").style.display="none";
    }
    else
    {
        document.getElementById("TrstContent").style.display="none";
        document.getElementById("TrStyleID").style.display="";
    }
}
function ReturnDivValue()
{
    var temproot = "";
    var rvalue="[NT:Loop,NT:LabelType=ChannelContent";
    
    if(document.ListLabel.StyleID.value=="0")
    { temproot = "[#NT:StyleID=" + document.ListLabel.gstyleID.value+"]"; }
    else
    { 
        //var oEditor = FCKeditorAPI.GetInstance("UserDefined");
        temproot = document.getElementById("UserDefined").value;
    }
    rvalue += "]";
    rvalue += temproot;
    rvalue += "[/NT:Loop]";
    parent.getValue(rvalue);
}

function CloseDiv()
{
    parent.document.getElementById("LabelDivid").style.display="none";
}

function getValue(value)
{
   document.all.UserDefined.focus();
   var tarobj = document.selection.createRange();
   tarobj.text = value;

//    var oEditor = FCKeditorAPI.GetInstance("UserDefined");
//    if (oEditor.EditMode==FCK_EDITMODE_WYSIWYG)
//    {
//       oEditor.InsertHtml(value);
//    }else
//    {
//        return false;
//    }
} 
</script>